﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <td class="formTitle"><span class="required">*</span>名称：</td>
                <td class="formValue">
                    <input id="Name" name="Name" type="text" class="form-control required" placeholder="请输入名称" />
                </td>
            </tr>
            <tr>
                <td class="formTitle"><span class="required">*</span>编码：</td>
                <td class="formValue">
                    <input id="Code" name="Code" type="text" class="form-control required" placeholder="请输入编码" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>Value：</th>
                <td class="formValue">
                    <input id="Value" name="Value" type="text" class="form-control required" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">说明：</th>
                <td class="formValue">
                    <input id="Memo" name="Memo" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序：</th>
                <td class="formValue">
                    <input id="px" name="px" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">状态：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="formValue" style="padding-top: 1px;">
                    <input id="OrganizeId" name="OrganizeId" type="hidden">
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/SysConfig/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data[0]);
                }
            });
        }
    });

    function initControl() {

    }

    function AcceptClick(callBack) {
        if (!$('#form1').formValid()) {
            return false;
        }

        var postData = $("#form1").formSerialize();
        if ($('#OrganizeId').val() == "" || $('#OrganizeId').val() == null)
        {
            keyValue = "";
        }

        $.submitForm({
            url: "/SystemManage/SysConfig/SubmitForm?keyValue=" + keyValue,
            param: postData,
            success: function () {
                callBack();
                $.modalClose();
            }
        })
    }
</script>

